package com.myschool.dao;

import com.myschool.entity.Subject;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface SubjectDao {

    @Select("select * from subject")
    List<Subject> getAll();

    @Select("select * from subject where subjectNo=#{subjectNo}")
    Subject getOne(Integer subjectNo);

    @Insert("INSERT INTO `myschool`.`subject` ( `subjectNo`, `subjectName`, `classHour`, `gradeID` ) " +
            "VALUES ( NULL, #{subjectName}, #{classHour}, #{gradeID} ) ; ")
    void add(Subject subject);

    @Update("UPDATE `myschool`.`subject` " +
            "SET `subjectName` = #{subjectName}," +
            " `classHour` = #{classHour}," +
            " `gradeID` = #{gradeID}" +
            " WHERE `subjectNo` = #{subjectNo} ;")
    void update(Subject subject);

    @Delete("delete from subject WHERE `subjectNo` = #{subjectNo} ;")
    void delete(Integer subjectNo);
}
